<?php


namespace App\Http\Repositories\Daos\Impls;


use App\Http\Repositories\Daos\IProductItemDao;
use App\Http\Repositories\Eloquent\ProductItem;

class ProductItemDao extends BaseDao implements IProductItemDao
{
    public function __construct(ProductItem $model)
    {
        parent::__construct($model);
    }

    public function byProductId($id, $productSiteId = 0)
    {
        $filterMap = $this->model->newQuery();
        $filterMap->where('product_id',$id);
        if ($productSiteId) {
            $filterMap->where('product_site_id', $productSiteId);
            return $filterMap->first();
        } else {
            return $filterMap->get();
        }

    }


}